package com.foreveross.taskservice.taskcache.redis.util;

import java.util.Date;

/**
 * 任务的优先级工具类
 * @author Administrator
 *
 */
public class TaskScopeUtil {
	
	
	public static double getDoingQueueScope(){
		return getDoingQueueScope(new Date());
	}
	public static double getDoingQueueScope(Date d){
		return Double.valueOf(d.getTime()+"");
	}
	public static double getFinishQueueScope(Date d,int status){
		return Double.valueOf(status+"."+d.getTime());
	}
	public static double getFinishQueueScope(int status){
		return getFinishQueueScope(new Date(),status);
	}
	
	public static double getWaitQueueScope(int taskPriority){
		return getWaitQueueScope(taskPriority,new Date());
	}
	public static double getWaitQueueScope(int taskPriority,Date d){
		return Double.valueOf(taskPriority+"."+d.getTime());
	}
	
	/**
	 * 根据状态获取完成队列中的两个优先级
	 * @param status
	 * @return
	 */
	public static double[] getFinishQueueMinMaxScope(int status){
		double[] result=new double[2];
		if(status>=0){
			result[0]=status;
			result[1]=status+0.9999999999;
		}else{
			result[0]=status-0.9999999999;
			result[1]=status;
		}
		return result;
	}
	
}
